home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.xml;
-
- import com.extensibility.plugin.PluginRegistry;
- import com.extensibility.plugin.api.URIScheme;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.Reader;
- import java.io.Writer;
- import java.net.URL;
-
- public class URI {
- private URIScheme scheme;
- private URI baseURI = null;
- private String relPath = null;
- private static int RO_UNDETERMINED = 0;
- private static int IS_READ_ONLY = 1;
- private static int IS_WRITEABLE = 2;
- private int readOnlyState;
- private static URISchemeRegistry registry = new URISchemeRegistry();
- private static URIScheme virginScheme = new VirginURIScheme();
- public static final String STRING_SCHEME = ":xa-string";
- public static final String VIRGIN_SCHEME = ":xa-virgin";
- public static final String FILE_SCHEME = "file";
-
- public static URISchemeRegistry getRegistry() {
- return registry;
- }
-
- public static void registerSchemes() {
- PluginRegistry var0 = PluginRegistry.getRegistry();
- int var1 = var0.getPluginApiCount("URIScheme10");
-
- for(int var2 = 0; var2 < var1; ++var2) {
- Object var3 = var0.getNthPlugin("URIScheme10", var2);
- URIScheme var4 = (URIScheme)var3;
- if (var4 != null) {
- var4.registerSchemes(registry);
- }
- }
-
- }
-
- public static void registerUsualSchemes() {
- (new URIFileScheme()).registerSchemes(registry);
- (new URIUrlScheme()).registerSchemes(registry);
- (new URIStringScheme()).registerSchemes(registry);
- }
-
- public static URI makeStringURI(String var0) {
- URIScheme var1 = registry.makeURIScheme(Class.forName("java.lang.String"), var0);
- return new URI(var1);
- }
-
- public URI() {
- this.readOnlyState = RO_UNDETERMINED;
- this.scheme = virginScheme;
- }
-
- public URI(File var1) {
- this.readOnlyState = RO_UNDETERMINED;
- this.scheme = registry.makeURIScheme(Class.forName("java.io.File"), var1);
- this.relPath = this.scheme.getFullPath();
- }
-
- public URI(URIScheme var1) {
- this.readOnlyState = RO_UNDETERMINED;
- this.scheme = var1;
- this.relPath = var1.getFullPath();
- }
-
- public URI(URL var1) {
- this.readOnlyState = RO_UNDETERMINED;
- this.scheme = registry.makeURIScheme(Class.forName("java.net.URL"), var1);
- this.relPath = this.scheme.getFullPath();
- }
-
- public URI(String var1) {
- this.readOnlyState = RO_UNDETERMINED;
- this.buildURI(var1);
- }
-
- private String extractScheme(String var1, boolean var2) {
- String var3 = null;
- int var4 = var1.indexOf(58);
- if (var4 >= 0) {
- var3 = var1.substring(0, var4);
- if (var2 && !registry.isValidSchemeName(var3)) {
- var3 = null;
- }
- }
-
- return var3;
- }
-
- private void buildURI(String var1) {
- this.relPath = var1;
- String var2 = this.extractScheme(var1, false);
- if (var2 != null) {
- this.scheme = registry.makeURIScheme(var2, var1);
- }
-
- if (this.scheme == null) {
- if (var1.length() > 0) {
- this.scheme = registry.makeURIScheme(Class.forName("java.io.File"), new File(var1));
- } else {
- this.scheme = virginScheme;
- }
- }
-
- }
-
- public URI(URI var1, String var2) {
- for(this.readOnlyState = RO_UNDETERMINED; var1 != null && !var1.hasPersistence(); var1 = var1.getBaseURI()) {
- }
-
- boolean var3 = var2.startsWith("x-schema:");
- if (var3) {
- var2 = var2.substring(9);
- }
-
- if (var1 != null && this.extractScheme(var2, true) == null) {
- this.relPath = var2;
- this.scheme = var1.scheme.construct(var2);
- this.baseURI = var1;
- } else {
- this.buildURI(var2);
- }
-
- }
-
- private URI(URI var1, URIScheme var2) {
- this.readOnlyState = RO_UNDETERMINED;
- this.scheme = var2;
- this.baseURI = var1;
- }
-
- public URIScheme getSchemeObject() {
- return this.scheme;
- }
-
- public URI getParent() {
- URIScheme var1 = this.scheme.toParent();
- return var1 != null ? new URI(var1) : null;
- }
-
- public String getRelativeName(URI var1) {
- String var2;
- if (this.scheme.getScheme().equals(var1.scheme.getScheme())) {
- var2 = this.scheme.computeRelative(var1.scheme);
- if (var2 == null) {
- var2 = this.scheme.getFullPath();
- }
- } else {
- var2 = this.scheme.getFullPath();
- }
-
- return var2;
- }
-
- public URI makeRelative(URI var1) {
- URI var2 = this;
- if (var1 != null) {
- if (this.scheme.hasPersistence()) {
- if (var1.scheme.getScheme().equals(this.scheme.getScheme())) {
- String var3 = this.scheme.computeRelative(var1.scheme);
- if (var3 != null) {
- var2 = new URI(var1, var3);
- }
- }
- } else {
- var2 = new URI(var1, this.scheme);
- }
- }
-
- return var2;
- }
-
- public URI getBaseURI() {
- return this.baseURI;
- }
-
- public String getScheme() {
- return this.scheme.getScheme();
- }
-
- public long getLength() {
- return this.scheme.getLength();
- }
-
- public URI renameTo(String var1) {
- return new URI(this.scheme.renameTo(var1));
- }
-
- public InputStream createInputStream() throws IOException {
- return this.scheme.createInputStream();
- }
-
- public Reader createReader() throws IOException {
- return this.scheme.createReader();
- }
-
- public XMLReader createXMLReader() throws IOException {
- return new XMLReader(this.scheme.createInputStream());
- }
-
- public Writer createWriter(int var1) throws IOException {
- return new XMLWriter(this.scheme.createOutputStream(), var1);
- }
-
- public Writer createWriter() throws IOException {
- return this.scheme.createWriter();
- }
-
- public boolean hasPersistence() {
- return this.scheme.hasPersistence();
- }
-
- public boolean isEmpty() {
- return this.scheme.isEmpty();
- }
-
- public boolean equals(URI var1) {
- return var1 != null && this.scheme.getScheme().equals(var1.scheme.getScheme()) && this.scheme.equals(var1.scheme);
- }
-
- public int compareTo(URI var1) {
- int var2 = this.scheme.getScheme().compareTo(var1.scheme.getScheme());
- if (var2 == 0) {
- var2 = this.scheme.compareTo(var1.scheme);
- }
-
- return var2;
- }
-
- public boolean exists() {
- return this.scheme.exists();
- }
-
- public boolean isReadOnly() {
- return this.isReadOnly(false);
- }
-
- public boolean isReadOnly(boolean var1) {
- if (this.readOnlyState == RO_UNDETERMINED || var1) {
- this.readOnlyState = this.scheme.isReadOnly() ? IS_READ_ONLY : IS_WRITEABLE;
- }
-
- return this.readOnlyState == IS_READ_ONLY;
- }
-
- public int hashCode() {
- return this.getShortName().hashCode() ^ 1234321;
- }
-
- public String getShortName() {
- return this.scheme.getShortName();
- }
-
- public String getFullName() {
- return this.scheme.getFullPath();
- }
-
- public String getUIName() {
- return this.scheme.getUIName();
- }
-
- public String toSource() {
- return this.relPath;
- }
-
- public Object getInterface(Class var1) {
- return this.scheme.getInterface(var1);
- }
- }
-